<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row" style="margin: 0;">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="deptId" name="deptId" value="${sysDept.deptId!}"
                               class="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label ">上级部门：</label>
                            <div class="col-sm-8">
                                <input value="${parentDeptName!}"
                                       class="form-control" type="text" readonly="true"/>
                                <input class="form-control hidden" type="text" id="parentId" name="parentId"
                                       value="${parentId!}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">部门编号：</label>
                            <div class="col-sm-8">
                                <input id="deptCode" name="deptCode" class="form-control" value="${sysDept.deptCode!}" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">部门名称：</label>
                            <div class="col-sm-8">
                                <input id="name" name="name" value="${sysDept.name!}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input id="orderNum" name="orderNum" value="${sysDept.orderNum!}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-8">
                                <select id="delFlag" name="delFlag" class="form-control">
                                    <option value="1" <#if '${sysDept.delFlag!}'== '1'>selected</#if>>正常</option>
                                    <option value="0" <#if '${sysDept.delFlag!}'== '0'>selected</#if>>禁用</option>
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(function() {
	    validateRule();
});
function update() {
        var url="/system/sysDept/update";
        var id =$("#deptId").val();
        if(id==null||id==''||id==undefined){
            url  ="/system/sysDept/save";
        }
        postAjax(url,$('#signupForm').serialize(),function(data){
                layer.msg("操作成功");
                reLoadTree();
                // var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                layer.close(current_index);
        });
}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			name : {
				required : true
			}
		},
		messages : {
			name : {
				required : icon + "请输入名字"
			}
		},
		 submitHandler: function (form) {
                update();
            },
            invalidHandler: function (form, validator) {
                return false;
            }
	})
}

</script>